#include <iostream>
using namespace std;

class Person 
{
public:
    Person(){
        cout<< "Person()"<<endl;
    }
    virtual ~Person(){
        cout<< "~Person()"<<endl;
    }
    virtual void work() = 0;
    void setName(const string &name){
        this->name = name;  
    }
    string getName() const{
        return name;
    }
protected:
    string name;     
};

class Student: virtual public Person
{
public:
    Student(){
        cout<< "Student()"<<endl;
    }
    virtual ~Student(){
        cout << "~Student()"<<endl;
    }
    virtual void work(){
        cout <<"Student::work()"<<endl;
    }
};
int main()
{
/*
抽象类不能实例化
 如果在派生类中不实现纯虚函数，派生类也将是抽象类
*/
    Person *s = new Student;
    s->work();
    s->setName("yzw2022");
    cout << "name: " << s->getName() << endl;
    delete s;
    s = nullptr;
    return 0;
}